﻿using B.S.DataBase.MyProject.Domain.Clients;
using B.S.DataBase.MyProject.Domain.Vendors;
using B.S.DataBase.MyProject.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using T.E.ERP.Read.API.Applicantions.Command.CientsCommand.QuearyClientsCommands;
using T.E.ERP.Read.API.Applicantions.Command.CientsCommand.QuearyCustomerCommands;
using T.E.ERP.Read.API.Applicantions.Command.GetIcesandCommand;
using T.E.ERP.Read.API.Dtos.Dtos;

namespace T.E.ERP.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class CustomermanageController : ControllerBase
    {
        private readonly IMediator mediator;

        public CustomermanageController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 用户档案查询
        /// </summary>
        /// <param name="CustomerName"></param>
        /// <param name="Contact"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<CustomerProfiles>>> GetCustomers(string? CustomerName,string? Contact)
        {
            QuearyClientsCommand command = new QuearyClientsCommand();
            command.CustomerName = CustomerName;
            command.Contact = Contact;
            return await mediator.Send(command);
        }
        /// <summary>
        /// 动态查询供应商
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<MaterialSupplier>>> GetMaterial([FromQuery]GetMaterialSupperComand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 开票到票查询
        /// 物联网-智能MES生产管理系统-07-开票到票管理V1.1-20250206
        /// </summary>
        /// <param name="get"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<ApiPaging<BillingderDto>>> GetBillist([FromQuery] GetIencesandCommand get)
        {
            return await mediator.Send(get);
        }

        /// <summary>
        /// 开票到票订单查询
        /// 物联网-智能MES生产管理系统-07-开票到票管理V1.1-20250206
        /// </summary>
        /// <param name="get"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<ApiPaging<UrchaseDto>>> Geturchase([FromQuery] GeturchaseCommand get)
        {
            return await mediator.Send(get);
        }
    }
}
